// pages/user-wddp/user-ddp.js
var util = require('../../utils/network.js')
Page({

    /**
     * 页面的初始数据
     */
    data: {
        stars: [0, 1, 2, 3, 4],
        normalSrc: '../../image/normal.png',
        selectedSrc: '../../image/selected.png',
        key: 1,//评分
        score: [
            { "text": "总体评价", "id": 0 },
            { "text": "准点率", "id": 1 },
            { "text": "舒适度", "id": 2 },
            { "text": "车辆服务", "id": 3 }
        ],
        scores: [0, 0, 0],
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        
    },
    //点击右边,半颗星
    selected: function (e) {
        var key = e.currentTarget.dataset.key
        this.data.scores[e.currentTarget.dataset.idx] = key,
        this.setData({
            scores: this.data.scores,
            key: key
        })
    },
    submit:function(){
        var token = util.token
        var that=this
        console.log(that.data.scores)
        wx.request({
            url: util.main + '/saveAssessment/0',
            data: {
                "orderno": 7687118148,
                "serve": that.data.scores[0],
                "punctuality": that.data.scores[1],
                "buysatisfy": that.data.scores[2],
                "ridesatisfy": that.data.scores[3],
                "clienttype":'weixx',
                "token": token,
                "deviceid": wx.getStorageSync('openId'),
                "userid": wx.getStorageSync("userId")
            },
            header: {
                "content-type": "application/json",
                "accept": "application/json,",
            },
            method: "POST",
            dataType: "json",
            success: function (res) {
                console.log(res)
                if (res.statusCode == 200) {
                }
            }
        })
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})